#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Zhangcl
import configparser
config=configparser.ConfigParser()
# config['h1'] = {
#     'hostname':'h1',
#     'ip':'192.168.3.74',
#     'user':'root',
#     'passwd':'simple',
#     'port':22
# }
# with open('H1.ini', 'w') as configfile:
#    config.write(configfile)
# hostname = input('hostname:')
# ip = input('ip:')
# user = input('user:')
# passwd = input('passwd:')
# config.add_section(hostname)
# config.set(hostname,'hostname',hostname)
# config.set(hostname,'ip',ip)
# config.set(hostname,'user',user)
# config.set(hostname,'passwd',passwd)
# config.write(open('H1.ini','a'))
config.read('H1.ini')
# for i in config.sections():
#     ret = config.items(i)
#     print(ret)
# config.read('H1.ini')
# config.remove_section('h2')
# config.write(open('H1.ini','w'))
s = config.sections()
for index, item in enumerate(s):
    print(index, item)